<%@page import="com.office.automate.model.employee.EmployeeSearch"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.List"%>
<%@page import="com.office.automate.exception.framework.FrontierVisibleException"%>
<%@page import="com.office.automate.configuration.property.DatagridPageConfiguration"%>
<%@page import="com.office.automate.frontier.utility.DataConversionUtility"%>
<%@page import="com.office.automate.configuration.property.ConfigurationProperties"%>
<%@page import="java.util.Properties"%>
<%@page import="com.office.automate.frontier.utility.ExceptionMessagesManagement"%>
<%@page import="com.office.automate.validation.framework.ValidatorObject"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ include file="../common/CommonHeaderInfo.jsp"%>
<title>Search</title>
</head>
<body>
	<%@ include file="../common/SiteHeaderSection.jsp" %>
	<%@ include file="../common/EmployeeManagementMenu.jsp"%>
		<%
			if (currentUser == null) {
				return;
			}
			Properties configSeqPropspg = ConfigurationProperties.getProps(); 
			Utility utilpg = new Utility(currentUser.getSecurityLevels());
			if (!utilpg.isFunctionalSecurityAllow(configSeqPropspg.getProperty("MAIN_EMPLOYEE_MANAGEMENT")) ||  
						!utilpg.isFunctionalSecurityAllow(configSeqPropspg.getProperty("EMPLOYEE_SEARCH")))  {
				response.sendRedirect("/OfficeAutomation/jsp/HomePage.jsp");
			}
			Properties configProps = ConfigurationProperties.getProps();
			DataConversionUtility dataconversion = new DataConversionUtility();
			String aDataGridPageID = DatagridPageConfiguration.EMPLOYEE_DETAILS;
			String aNextDataRowNumber = (String)request.getAttribute("NextDataRowNumber");
			EmployeeSearch employeeSearch = new EmployeeSearch();
			if ((EmployeeSearch) request.getAttribute("EmployeeSearch") != null) {
				employeeSearch = (EmployeeSearch) request.getAttribute("EmployeeSearch");
			}
			FrontierVisibleException operationalExcaption = (FrontierVisibleException) request.getAttribute("OperationalError");
			if (operationalExcaption != null) {
		%>
		<tr>
			<td>
				<table width="100%" class="operationfaliererror">
					<tr>
						<td>
							<center>
								<font class="operationfaliererrorfont"> <b> Opps.....!!! <%=operationalExcaption.getDetailsErrorMessage() %> </b> <br /> </font>
							</center>
						</td>
					</tr>
		
				</table>
			</td>
		</tr>
		<% } %>
		<tr>
			<td>
				<form action="/OfficeAutomation/SearchEmployeeServlet" method="post">
					<center>
						<table>
							<tr>
								<td>
									<center><font class="formtablecaption"><u>Employee Detail Search</u></font></center><br />
									<table class="mainContentStyles">
										<tr>
											<td>Employee Id</td>
											<td><input type="text" name="employeeId" size="7" <% if (employeeSearch.getEmployeeId() > 0) { %> value="<%=employeeSearch.getEmployeeId() %>" <% } %>></td>
											<td></td><td></td>
											<td></td><td></td>
										</tr>
										<tr>
											<td>First Name</td>
											<td><input type="text" name="firstName" <% if (isStringSet(employeeSearch.getFirstName())) { %> value="<%=employeeSearch.getFirstName() %>" <% } %>></td>
											
											<td>Middle Name</td>
											<td><input type="text" name="middleName" <% if (isStringSet(employeeSearch.getMiddleName())) { %> value="<%=employeeSearch.getMiddleName() %>" <% } %>></td>
											
											<td>Last Name</td>
											<td><input type="text" name="lastName" <% if (isStringSet(employeeSearch.getLastName())) { %> value="<%=employeeSearch.getLastName() %>" <% } %>></td>
										</tr>
										<tr>
											<td>NIC</td>
											<td><input type="text" name="niceNumber" size="11" <% if (isStringSet(employeeSearch.getNic())) { %> value="<%=employeeSearch.getNic() %>" <% } %>></td>
											<td></td><td></td>
											<td></td><td></td>
										</tr>
										<tr>
											<td>E-mail</td>
											<td colspan="2"><input type="text" name="emailAddress" size="40" <% if (isStringSet(employeeSearch.getEmail())) { %> value="<%=employeeSearch.getEmail() %>" <% } %>></td>
											<td></td>
											<td></td><td></td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td colspan="2"><div class="formButtonPanel"><input type="reset" class="buttonstyle"> <input class="buttonstyle" type="submit" name="search" value="Search" /></div></td>
							</tr>
						</table>
					</center>
				 </form>
			</td>
		</tr>
		<tr>
			<td height="20px">
			
			</td>
		</tr>
		<tr>
			<td>
				<center>
				        <jsp:include page="../frameworks/SearchDataGridComponent.jsp">
			            	<jsp:param name="aDataGridPageID" value="<%=aDataGridPageID %>" />
			            	<jsp:param name="aNextRowNumber" value="<%=aNextDataRowNumber %>" />
			            	<jsp:param name="anEmployeeId" value="<%=employeeSearch.getEmployeeId() %>" />
			            	<jsp:param name="aFirstName" value="<%=employeeSearch.getFirstName() %>" />
			            	<jsp:param name="aMiddleName" value="<%=employeeSearch.getMiddleName() %>" />
			            	<jsp:param name="aLastName" value="<%=employeeSearch.getLastName() %>" />
			            	<jsp:param name="aNICNumber" value="<%=employeeSearch.getNic() %>" />
			            	<jsp:param name="anEmailAddress" value="<%=employeeSearch.getEmail() %>" />
			            	<jsp:param name="aButtonDeleteCaption" value="Delete" />
			            	<jsp:param name="aButtonUpdateCaption" value="Update" />
			            	<jsp:param name="aButtonOtherCaption" value="View" />
			            	<jsp:param name="aButtonsNextPrevious" value="true" />
			        	</jsp:include>
				</center>
			</td>
		</tr>
<%!

	public boolean isStringSet(String param) {
	    if (param != null && !"null".equals(param) && !param.isEmpty()) {
	    	return true;
	    }
	    return false;
	 }
%>
<%@ include file="../common/SiteFotterSection.jsp" %>
</body>
</html>